﻿<ItemsControl x:Class="NETXPF.WPF.PropertyList.PropertyList"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:me="clr-namespace:NETXPF.WPF.PropertyList"
             xmlns:wpf="clr-namespace:NETXPF.WPF"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <ItemsControl.Resources>
        <ResourceDictionary>
            <Style x:Key="NameStyle" TargetType="{x:Type TextBlock}">
                <Setter Property="Width" Value="120"></Setter>
                <Setter Property="TextWrapping" Value="Wrap"></Setter>
                <Setter Property="Padding" Value="2"></Setter>
            </Style>
            <Style x:Key="ItemStyle" TargetType="{x:Type Panel}">
                <Setter Property="Margin" Value="6,2"></Setter>
            </Style>
            <me:EnumDisplayer x:Key="enumValues"></me:EnumDisplayer>
            <me:NumericConverter x:Key="numericConverter"></me:NumericConverter>
            <DataTemplate x:Key="Default_StringTemplate">
                <TextBox IsEnabled="{Binding IsEnabled}" Text="{Binding Value}"></TextBox>
            </DataTemplate>
            <DataTemplate x:Key="Default_MultilineTemplate">
                <TextBox IsEnabled="{Binding IsEnabled}" Text="{Binding Value}">
                    <TextBox.Style>
                        <Style TargetType="TextBox">
                            <Setter Property="MaxLines" Value="3"></Setter>
                            <Setter Property="MinLines" Value="3"></Setter>
                            <Setter Property="AcceptsReturn" Value="True"></Setter>
                            <Setter Property="VerticalScrollBarVisibility" Value="Auto"></Setter>
                            <Setter Property="TextWrapping" Value="Wrap"></Setter>
                        </Style>
                    </TextBox.Style>
                </TextBox>
            </DataTemplate>
            <DataTemplate x:Key="Default_EnumTemplate">
                <ComboBox IsEnabled="{Binding IsEnabled}" ItemsSource="{Binding Path=Value, Converter={StaticResource enumValues}, ConverterParameter=AllValues}"
                              SelectedValue="{Binding Path=Value, Converter={StaticResource enumValues}}"></ComboBox>
            </DataTemplate>
            <DataTemplate x:Key="Default_DateTemplate">
                <wpf:DateTimePicker IsEnabled="{Binding IsEnabled}" DateTimeSelected="{Binding Value}"></wpf:DateTimePicker>
            </DataTemplate>
            <DataTemplate x:Key="Default_NumericTemplate">
                <TextBox IsEnabled="{Binding IsEnabled}" Text="{Binding Value, Converter={StaticResource numericConverter}}"></TextBox>
            </DataTemplate>
            <DataTemplate x:Key="Default_UnknownTemplate">
                <StackPanel Orientation="Horizontal">
                    <Button IsEnabled="{Binding IsEnabled}" Name="zEdit" Click="zEdit_Click">_Edit...</Button>
                </StackPanel>
            </DataTemplate>
            <DataTemplate x:Key="Default_Hidden">
            </DataTemplate>
        </ResourceDictionary>
    </ItemsControl.Resources>
    <ItemsControl.ItemTemplate>
        <DataTemplate>
            <DockPanel Visibility="{Binding ItemVisibility}" Style="{StaticResource ItemStyle}">
                <TextBlock Style="{StaticResource NameStyle}" Name="zName" Text="{Binding PropertyName}"></TextBlock>
                <ContentPresenter Content="{Binding}">
                    <ContentPresenter.ContentTemplateSelector>
                        <me:PropertyItemSelector></me:PropertyItemSelector>
                    </ContentPresenter.ContentTemplateSelector>
                </ContentPresenter>
            </DockPanel>
        </DataTemplate>
    </ItemsControl.ItemTemplate>
    <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
            <StackPanel Orientation="Vertical"></StackPanel>
        </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>
</ItemsControl>
